<template>
	<view>
		<view class="header">
			
			<image v-if="data.litpic" class="img" mode="scaleToFill" :src="data.litpic"></image>
		</view>
		<view class="container">
			<rich-text :nodes="data.body"></rich-text>
		</view>
		
		
	</view>
</template>

<script>
	var config = require('../common/util.js');
	
	export default {
		data() {
			return {
				data:[],
			}
		},
		onLoad() {
			uni.setNavigationBarTitle({
				title:'关于我们'
			})
			this.getdata()
		},
		onShow(){
			// #ifdef MP-BAIDU
			swan.setPageInfo({
				title: this.data.classname,
				keywords: '极致CMS,企业建站,免费CMS,开源CMS,免费商用CMS,资讯小程序',
				description: '这是一个免费商用的极致新闻资讯小程序，赶紧来分享使用吧！',
				articleTitle: '功能强大，免费开源CMS，免费商用的小程序源码！',
				releaseDate: config.nowday(),
				image: [
					this.data.litpic ? this.data.litpic : '/static/banner.png'
				],
				/*
				video: [{
					url: 'https://www.baidu.com/mx/v12.mp4',
					duration: '100',
					image: 'https://ms-static.cdn.bcebos.com/miniappdocs/img/image-scaleToFill.png'
				}],
				visit: {
					pv: '1000',
					uv: '100',
					sessionDuration: '130'
				},
				
				likes: '75',//点赞
				comments: '13',//评论
				collects: '23',//收藏
				shares: '8',//分享
				followers: '35',//关注
				*/
				success: res => {
					console.log('setPageInfo success', res);
				},
				fail: err => {
					console.log('setPageInfo fail', err);
				}
			})
			// #endif
		},
		
		// 自定义此页面的转发给好友(已经有全局的分享方法，此处会覆盖全局)
		onShareAppMessage(res) {
		    return {
		      title: this.data.classname,
		      path: '/pages/about',
			  imageUrl: this.data.litpic ? this.data.litpic : '/static/banner.png'
		    }
		  },
		  // 自定义页面的分享到朋友圈
		onShareTimeline(res) {
			return {
				title: this.data.classname,
				path: '/pages/about',
				imageUrl: this.data.litpic ? this.data.litpic : '/static/banner.png'
			}
		},
		methods:{
			
			getdata(){
				var that = this;
				uni.request({
					  url: config.webapi+'/getData/getclass',
					  data: {
							  key:config.apikey,
							  model:'classtype',
							  id:3
						  },
					  success: (res) => {
						 // console.log(res.data);
						  if(res.data.code!=0){
							  uni.showToast({
								title: res.data.msg,
								duration: 2000,
								icon :'error'
							  });
						  }
						  let len = res.data.data.length;
						  for(var i=0;i<len;i++){
							  if(res.data.data[i].litpic){
								  res.data.data[i].litpic = res.data.data[i].litpic.indexOf('http')>-1 ? res.data.data[i].litpic : config.filepath+res.data.data[i].litpic;
								  	 
							  }
							  
							
						  }
						  var reg = /src=\"([^"]+)\"/;
						  var www = config.filepath;
						  res.data.data[0].body = res.data.data[0].body.replace(reg,function(a){
						  	if(a.indexOf('//')==-1){
						  		return a.replace( /src=\"([^"]+)\"/,"src=\""+www+"$1\"" );
						  	}
						  	
						  });
						 that.data = res.data.data[0];
						 
						
						 
					  },
				})
			},
			
			
			
		}
		
		
	}
	
</script>

<style>
	.title{
		    text-align: center;
		    margin: 20px;
		    font-size: 20px;
	}
	.img{
		width: 100%;
	}
	.container{
		    padding: 15px;
		    line-height: 25px;
	}

</style>